package com.aegis.manage.controller.sys;

import cn.dev33.satoken.stp.StpUtil;
import com.aegis.core.model.AegisLoginInfo;
import com.aegis.manage.api.request.LoginRequest;
import com.aegis.manage.service.sys.login.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author renogo
 *
 * @Version 1.0
 * @Descritube
 */
@RestController
@RequestMapping("/sys/auth")
@Api(tags = "系统-认证模块")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "用户登录")
    @PostMapping("/login")
    public AegisLoginInfo login(@Validated @RequestBody LoginRequest loginRequest) {
        return loginService.login(loginRequest);
    }


    @ApiOperation(value = "登出")
    @PostMapping("/logout")
    public void logOut() {
        StpUtil.logout();
    }


}
